<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
*{padding: 0;margin: 0;}
    </style>

</head>
<body>
    <button id='btn'>全屏按钮</button>  
    <div id="content" style="background:yellow;width:500px;height:500px;">  
        <div id="quite" class="btn">退出全屏</div>  
    </div>  
</body>
<script type="text/javascript">
    function fullScreen(el) {
        var rfs = el.requestFullScreen || el.webkitRequestFullScreen || el.mozRequestFullScreen || el.msRequestFullScreen,  
            wscript;
            if(typeof rfs != "undefined" && rfs) {
                rfs.call(el);
                return;  
            }
            if(typeof window.ActiveXObject != "undefined") {  
                wscript = new ActiveXObject("WScript.Shell");  
                // console.log(wscript)
                if(wscript) {  
                    wscript.SendKeys("{F11}");  
                }
            }
    }  
      
    function exitFullScreen(el) {  
        var el= document,  
            cfs = el.cancelFullScreen || el.webkitCancelFullScreen || el.mozCancelFullScreen || el.exitFullScreen,  
            wscript;  
       
        if (typeof cfs != "undefined" && cfs) {  
          cfs.call(el);  
          return;  
        }  
       
        if (typeof window.ActiveXObject != "undefined") {  
            wscript = new ActiveXObject("WScript.Shell");  
            if (wscript != null) {  
                wscript.SendKeys("{F11}");  
            }  
      }  
    }  

        var btn = document.getElementById('btn');
        var content = document.getElementById('content');
        // 这里只能手动触发全屏操作，这是浏览器的一种防御机制。
        btn.onclick = function(){
            fullScreen(content);
        }        
        var quite = document.getElementById('quite');  
        quite.onclick = function(){  
            exitFullScreen();  
        }  
 </script>
</html>